@extends('layouts.home')
@section('title', '犯二青年博客-平淡的开发者~')
@section('content')
    <section class="container">
        <div class="content-wrap">
            <div class="content">
                <div class="jumbotron">
                    <h1>欢迎访问犯二青年博客</h1>
                    <p>在这里可以看到前端技术，后端程序，网站内容管理系统等文章，还有我的程序人生！</p>
                </div>
                <div id="focusslide" class="carousel slide" data-ride="carousel">
                    <ol class="carousel-indicators">
                        <li data-target="#focusslide" data-slide-to="0" class="active"></li>
                        <li data-target="#focusslide" data-slide-to="1"></li>
                        <li data-target="#focusslide" data-slide-to="2"></li>
                    </ol>
                    <div class="carousel-inner" role="listbox">
                        @php
                            $active = 0;
                        @endphp
                        @if(!Cache::get('banner_article')->isEmpty())
                            @foreach(Cache::get('banner_article') as $bannerArticle)
                                @if($active == 0)
                                    <div class="item active">
                                        <a href="{{ url('/article/' . $bannerArticle->id) }}" target="_blank">
                                            <img src="{{ qiniu_url($bannerArticle->cover) }}"
                                                 alt="{{ $bannerArticle->title }}" class="img-responsive">
                                        </a>
                                    </div>
                                    @php
                                        $active = Cache::get('banner_article')[0]->id
                                    @endphp
                                @else
                                    <div class="item">
                                        <a href="{{ url('/article/' . $bannerArticle->id) }}" target="_blank">
                                            <img src="{{ qiniu_url($bannerArticle->cover) }}"
                                                 alt="{{ $bannerArticle->title }}" class="img-responsive">
                                        </a>
                                    </div>
                                @endif
                            @endforeach
                        @else
                            <div class="item active">
                                <a href="{{ url('/') }}" target="_blank">
                                    <img src="{{ url('/images/404/right.png') }}"
                                         alt="暂无文章" class="img-responsive">
                                </a>
                            </div>
                        @endif
                    </div>
                    <a class="left carousel-control" href="#focusslide" role="button" data-slide="prev" rel="nofollow">
                        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true">

                        </span>
                        <span class="sr-only">
                            上一个
                        </span>
                    </a>
                    <a class="right carousel-control" href="#focusslide" role="button" data-slide="next" rel="nofollow">
                        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true">

                        </span>
                        <span class="sr-only">
                            下一个
                        </span>
                    </a>
                </div>
                <article class="excerpt-minic excerpt-minic-index">
                    @if(! empty(Cache::get('today_recommend')))
                        <h2>
                        <span class="red">
                            【今日推荐】
                        </span>
                            <a href="{{ url('/article/' . Cache::get('today_recommend')->id) }}"
                               title="{{ Cache::get('today_recommend')->title }}">
                                {{ Cache::get('today_recommend')->title }}
                            </a>
                        </h2>
                        <p class="note">
                            {{ Cache::get('today_recommend')->description }}
                        </p>
                    @else
                        <h2>
                        <span class="red">
                            【暂无推荐】
                        </span>
                            <a href="{{ url('/') }}" title="暂无推荐">
                                欢迎访问犯二青年博客！
                            </a>
                        </h2>
                        <p class="note">
                            等待作者发布文章...
                        </p>
                    @endif

                </article>
                <div class="title">
                    <h3>最新发布</h3>
{{--                    <div class="more">--}}
{{--                        @foreach($tags as $tag)--}}
{{--                            <a href="/tags/{{ $tag->id }}">{{ $tag->name }}</a>--}}
{{--                        @endforeach--}}
{{--                    </div>--}}
                </div>

                @foreach($articles as $article)
                    <article class="excerpt excerpt-1">
                        <a class="focus" href="/article/{{ $article->id }}" title="">
                            <img class="thumb" data-original="{{ qiniu_url($article->cover) }}"
                                 src="{{ qiniu_url($article->cover) }}" alt="">
                        </a>
                        <header>
                            <a class="cat" href="/category/{{$article->category->id}}">{{ $article->category->name }}
                                <i></i>
                            </a>
                            <h2>
                                <a href="/article/{{ $article->id }}" title="">{{ $article->title }}
                                </a>
                            </h2>
                        </header>
                        <p class="meta">
                            <time class="time">
                                <i class="glyphicon glyphicon-time">

                                </i>{{ $article->updated_at }}
                            </time>
                            <span class="views">
                        <i class="glyphicon glyphicon-eye-open">

                        </i> 共{{ $article->click }}人围观
                    </span>
                            <a class="comment" href="/article/{{ $article->id }}">
                                <i class="glyphicon glyphicon-comment">

                                </i> {{ $article->getSumComments() ?? 0 }}条评论
                            </a>
                        </p>
                        <p class="note">{{ $article->description }}</p>
                    </article>
                @endforeach
                <nav class="pagination" style="display: none;">
                    <ul>
                        <li class="prev-page"></li>
                        <li class="next-page"><a href="{{ $articles->nextPageUrl() }}">下一页</a></li>
                    </ul>
                </nav>
            </div>
        </div>
        @include('layouts._right')
    </section>
@endsection
@section('script')
@endsection
